package com.example.idachuappone.index.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.idachuappone.R;
import com.example.idachuappone.utils.ImgCallBack;
import com.example.idachuappone.utils.Utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class ImgFileListAdapter extends BaseAdapter {
    Bitmap[] bitmaps;
    Context context;
    String filecount;
    String filename;
    List<View> holderlist;
    String imgpath;
    private int index;
    List<HashMap<String, String>> listdata;
    Utils util;

    class Holder {
        public TextView filecount_textview;
        public TextView filename_textView;
        public ImageView photo_imgview;

        Holder() {
        }
    }

    class AnonymousClass_1 implements ImgCallBack {
        private final /* synthetic */ int val$arg0;

        AnonymousClass_1(int i) {
            this.val$arg0 = i;
        }

        public void resultImgCall(ImageView imageView, Bitmap bitmap) {
            ImgFileListAdapter.this.bitmaps[this.val$arg0] = bitmap;
            imageView.setImageBitmap(bitmap);
        }
    }

    public ImgFileListAdapter(Context context, List<HashMap<String, String>> listdata) {
        this.filecount = "filecount";
        this.filename = "filename";
        this.imgpath = "imgpath";
        this.index = -1;
        this.context = context;
        this.listdata = listdata;
        this.bitmaps = new Bitmap[listdata.size()];
        this.util = new Utils(context);
        this.holderlist = new ArrayList();
    }

    public int getCount() {
        return this.listdata.size();
    }

    public Object getItem(int arg0) {
        return this.listdata.get(arg0);
    }

    public long getItemId(int arg0) {
        return (long) arg0;
    }

    public View getView(int arg0, View arg1, ViewGroup arg2) {
        Holder holder;
        if (arg0 == this.index || arg0 <= this.index) {
            holder = (Holder) ((View) this.holderlist.get(arg0)).getTag();
            arg1 = this.holderlist.get(arg0);
        } else {
            holder = new Holder();
            arg1 = LayoutInflater.from(this.context).inflate(R.layout.imgfileadapter, null);
            holder.photo_imgview = (ImageView) arg1.findViewById(R.id.filephoto_imgview);
            holder.filecount_textview = (TextView) arg1.findViewById(R.id.filecount_textview);
            holder.filename_textView = (TextView) arg1.findViewById(R.id.filename_textview);
            arg1.setTag(holder);
            this.holderlist.add(arg1);
        }
        holder.filename_textView.setText((CharSequence) ((HashMap) this.listdata.get(arg0)).get(this.filename));
        holder.filecount_textview.setText((CharSequence) ((HashMap) this.listdata.get(arg0)).get(this.filecount));
        if (this.bitmaps[arg0] == null) {
            this.util.imgExcute(holder.photo_imgview, new AnonymousClass_1(arg0), (String) ((HashMap) this.listdata.get(arg0)).get(this.imgpath));
        } else {
            holder.photo_imgview.setImageBitmap(this.bitmaps[arg0]);
        }
        return arg1;
    }
}
